Page({
    data: {
        xPageReady : false ,
        xQuiz : [] ,
        xright:0
    },

    onLoad: function (options) {
        let that =this;
        if(options.week){
          that.xget(Number(options.week))
        }else{
          that.setData({
            xQuiz : JSON.parse(options.total)
          })
          for(let index in that.data.xQuiz){
            for(let i in that.data.xQuiz[index].options){
              if(that.data.xQuiz[index].options[i].is_correct_answer == 1 && that.data.xQuiz[index].options[i].select== true){
                that.setData({
                    xright : that.data.xright+1
                })
              }
            }
          }
        }
    },
    xget(week){
      let that=this;
      let _dataObj = {
        week:week,
        // breakthrough_point:"after_teaching_reading" //对应after_teaching_reading字段说明
      }
      wx.cloud.callFunction({
          name: 'quiz_question',
          data: {
              action: "get_quiz_question_by_week",
              dataObj: _dataObj
          }
      }).then(res => {
        that.setData({
          xQuiz : res.result
        })
      })
      
    },
    xBack(){
       wx.switchTab({
         url: '/pages/navigation/using/index',
       })
    }
})